package com.kai.service.sms.controller;

import com.kai.service.data.Result;
import com.kai.service.data.request.sms.CheckSmsMailRequest;
import com.kai.service.data.request.sms.SendSmsMailRequest;
import com.kai.service.sms.service.ISmsMailService;
import com.kai.service.util.ResultResponseUtil;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

@RestController
@RequestMapping("/system")
@Tag(name = "短信")
public class SmsMailController {

    @Autowired
    private ISmsMailService smsCodeService;

    /**
     * 发送验证码
     *
     * @param sendSmsMailRequest
     */
    @PostMapping("/sms/code:send")
    @Operation(summary = "发送验证码")
    public Result<Boolean> sendSmsVerificationCode(@Valid @RequestBody SendSmsMailRequest sendSmsMailRequest){
        return ResultResponseUtil.success(smsCodeService.sendSmsVerificationCode(sendSmsMailRequest));
    }

    /**
     * 校验验证码
     *
     * @param checkSmsMailRequest
     */
    @PostMapping("/sms/code:check")
    @Operation(summary = "校验验证码")
    public Result<Boolean> checkSmsVerificationCode(@Valid @RequestBody CheckSmsMailRequest checkSmsMailRequest){
        return ResultResponseUtil.success(smsCodeService.checkSmsVerificationCode(checkSmsMailRequest));
    }
}
